package com.kexinde.wjifen.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.kexinde.wjifen.model.Shop;

@Component("shopDao")
public class ShopDao extends BaseDao<Shop> {

	@SuppressWarnings("unchecked")
	public Shop findById(long id) {
		List<Shop> shops = hibernateTemplate.find("from Shop s where s.id="
				+ id);
		if (null == shops || 0 == shops.size()) {
			return null;
		}
		return shops.get(0);
	}

	@SuppressWarnings("unchecked")
	public List<Shop> OrderByMoney(int num) {
		if(num <= 0){
			return null;
		}
		List<Shop> shops = hibernateTemplate.find("from Shop s order by s.registerMoney desc");
		if(num >= shops.size()){
			return shops;
		}
		return shops.subList(0, num);
	}

}
